|
|
|
|
|
|
|
Chapter 11
Drawing Curves |
|
|
|
|
|
|
|
|
Visual Basic comes with a reasonable assortment of drawing routines. Forms, picture boxes, and printer objects provide methods for drawing lines, circles, arcs, pie slices, boxes, and text. You can use these methods, particularly the Line method, to draw more complex shapes than those provided by Visual Basic directly. |
|
|
|
|
|
|
|
|
For example, you can use the Circle method to draw a circle. You can also use Circle to draw an ellipse with axes parallel to the X and Y axes. However, you cannot use this method to draw an ellipse that has been rotated by 30 degrees. Even the Windows API, which contains routines for drawing ellipses, arcs, chords, and pie slices, does not contain routines for drawing these objects rotated. If you want to display these shapes, you must draw them yourself. |
|
|
|
|
|
|
|
|
This chapter describes some of the issues you face when you want to display one of these shapes in Visual Basic. It shows how you can draw circles and rotated ellipses quickly and easily. |
|
|
|
|
|
|
|
|
It also describes several different types of curves you can use to represent data. Curves such as least square fits, splines, and Bezier curves follow a set of data points while providing a balance between close fit and smoothness. By following the general pattern of the points instead of following the points exactly, they show the overall shape of the data and can make patterns clear. |
|
|
|
|
|
|
|
|
Over the years programmers have developed extremely efficient algorithms for scan converting fundamental shapes like lines and circles. Bresenham's circle algorithm, for example, uses clever techniques to decide which pixels belong to a circle while minimizing the number of complex mathematical operations that would make the algorithm slow. |
|
|
|
|
|